package comlookupd

import (
	"errors"
	"gitee.com/liukexing/mqbroker/core/typedef"
)

func NewReplyHandle() map[string]func(interface{}) (interface{}, error) {
	return map[string]func(interface{}) (interface{}, error){
		"help": HelpMtd,
		"GetConfig":GetConfigMtd,
	}
}

func HelpMtd(data interface{}) (interface{}, error) {
	return data, nil
}

func GetConfigMtd(data interface{}) (interface{}, error)  {
	req := make(map[string]interface{})
	err := typedef.Decode(data,&req)
	if err != nil {
		return  nil,err
	}
	module := req["module"]
	if module != nil  {
		if v,ok := ConfigMap.Load(module.(string));ok {
			return v,nil
		}
	}
	return  nil,errors.New("req data error")
}
